/**
 * @description: 管理员管理
 */

import type { CommonAPI } from '../types/all'
import { defHttp } from '../http'

/** 获取管理员信息 */
export const getAdminDetailApi: CommonAPI<'/v1/admin', 'get'> = params =>
  defHttp.get(`/v1/admin`, { params })

/** 删除管理员 */
export const deleteAdminApi: CommonAPI<'/v1/admin', 'delete'> = params =>
  defHttp.delete(`/v1/admin`, { params })

/** 添加管理员 */
export const addAdminApi: CommonAPI<'/v1/admin', 'post'> = data =>
  defHttp.post(`/v1/admin`, data)

/** 更新管理员 */
export const updateAdminApi: CommonAPI<'/v1/admin', 'put'> = data =>
  defHttp.put(`/v1/admin`, data)

/** 登录 */
export const postAdminLoginApi: CommonAPI<'/v1/admin/login', 'post'> = data =>
  defHttp.post(`/v1/admin/login`, data)

/** 查询管理员登录记录 */
export const getAdminLoginRecordsApi: CommonAPI<
  '/v1/admin/login_records',
  'get'
> = params => defHttp.get(`/v1/admin/login_records`, { params })

/** 退出登录 */
export const deleteAdminLogoutApi: CommonAPI<
  '/v1/admin/logout',
  'delete'
> = params => defHttp.delete(`/v1/admin/logout`, { params })

/** 修改自己的密码 */
export const updateAdminPasswordApi: CommonAPI<
  '/v1/admin/password',
  'put'
> = data => defHttp.put(`/v1/admin/password`, data)

/** 重置管理员密码 */
export const updateAdminPasswordResetApi: CommonAPI<
  '/v1/admin/password/reset',
  'put'
> = data => defHttp.put(`/v1/admin/password/reset`, data)

/** 重置Google密钥 */
export const updateAdminResetGoogleSecretApi: CommonAPI<
  '/v1/admin/reset/google_secret',
  'put'
> = data => defHttp.put(`/v1/admin/reset/google_secret`, data)

/** 获取管理员列表 */
export const getAdminsListApi: CommonAPI<'/v1/admins', 'get'> = params =>
  defHttp.get(`/v1/admins`, { params })

/** 操作日志 */
export const getAdminsOptLogApi: CommonAPI<
  '/v1/operation_logs',
  'get'
> = params => defHttp.get(`/v1/operation_logs`, { params })
